# -*- coding: utf-8 -*-
"""
@Author: telson
@Email: telson.wu@qq.com
@Date: 2024/8/11
@Description: 
"""
import pyautogui
import pydirectinput

import time


def test():
    # 移动鼠标到屏幕的坐标(x=100, y=100)位置
    pyautogui.moveTo(100, 100)

    # 点击鼠标左键
    pyautogui.click()

    # 输入文本
    pyautogui.typewrite('Hello, world!')

    # 按下键盘上的'Enter'键
    pyautogui.press('enter')

    # 按下'Ctrl+C'键
    pyautogui.hotkey('ctrl', 'c')

    # 暂停2秒钟
    time.sleep(2)

    # 移动鼠标到屏幕的坐标(x=200, y=200)位置
    pyautogui.moveTo(200, 200, duration=2)


def go_forward():
    pydirectinput.press('w', 3, interval=1)
    print("go_forward")


def go_back():
    pydirectinput.press('s')
    print("go_back")


def go_left():
    pydirectinput.press('a')
    print("go_left")


def go_right():
    pydirectinput.press('d')
    print("go_right")


def forward_jump(t=1):
    pydirectinput.keyDown('w')
    pydirectinput.keyDown(' ')
    time.sleep(t)
    pydirectinput.keyUp(' ')
    pydirectinput.keyUp('w')


def back_jump(t=1):
    pydirectinput.keyDown('s')
    pydirectinput.keyDown(' ')
    time.sleep(t)
    pydirectinput.keyUp(' ')
    pydirectinput.keyUp('s')


def left_jump(t=1):
    pydirectinput.keyDown('a')
    pydirectinput.keyDown(' ')
    time.sleep(t)
    pydirectinput.keyUp(' ')
    pydirectinput.keyUp('a')


def right_jump(t=1):
    pydirectinput.keyDown('d')
    pydirectinput.keyDown(' ')
    time.sleep(t)
    pydirectinput.keyUp(' ')
    pydirectinput.keyUp('d')


def attack():
    pydirectinput.press('e')
    # pyautogui.click()
def defense_skill_1():
    attack()
    pydirectinput.keyDown('1')
    time.sleep(0.05)
    pydirectinput.keyUp('1')
    time.sleep(6)

def defense_skill_R():
    attack()
    time.sleep(0.05)
    pydirectinput.keyDown('r')
    time.sleep(0.05)
    pydirectinput.keyUp('r')
    time.sleep(6)

def foward_2_boss():
    pydirectinput.press('tab')
    time.sleep(0.05)
    pydirectinput.press('tab')
    forward_jump(1)


def test_move():
    go_forward()
    time.sleep(0.05)

    go_back()
    time.sleep(0.05)

    go_left()
    time.sleep(0.05)

    go_right()
    time.sleep(0.05)

    forward_jump()
    back_jump()
    left_jump()
    right_jump()

def test_skill():
    defense_skill_1()
    time.sleep(0.05)

    defense_skill_R()
    time.sleep(0.05)

    for i in range(5):
        print(i)
        attack()
        time.sleep(0.05)


if __name__ == '__main__':

    wait_time = 3
    for i in list(range(wait_time))[::-1]:
        print(i + 1)
        time.sleep(1)
        # forward_jump(1)

    # test_move()
    test_skill()
